package com.gitee.linzl;

import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.turbine.EnableTurbine;

@SpringBootApplication
@EnableDiscoveryClient
// 开启断路器装配
@EnableHystrix
@EnableHystrixDashboard
// 开启turbine
@EnableTurbine
public class HystrixServerBootstrap {
	/**
	 * 访问任意一个hystrix服务,如spring-hystrix-client服务: http://localhost:8081/hystrix
	 * 
	 * 输入spring-hystrix-server的turbine聚合服务: http://localhost:9081/turbine.stream
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		SpringApplicationBuilder builder = new SpringApplicationBuilder(HystrixServerBootstrap.class);
		builder.bannerMode(Banner.Mode.OFF);
		builder.run(args);
	}

	// @Bean
	// public ServletRegistrationBean<HystrixMetricsStreamServlet> getServlet() {
	// HystrixMetricsStreamServlet streamServlet = new
	// HystrixMetricsStreamServlet();
	// ServletRegistrationBean<HystrixMetricsStreamServlet> registrationBean = new
	// ServletRegistrationBean<>(
	// streamServlet);
	// registrationBean.setLoadOnStartup(1);
	// registrationBean.addUrlMappings("/hystrix.stream");
	// registrationBean.setName("HystrixMetricsStreamServlet");
	// return registrationBean;
	// }
}
